package com.gopay.common.cps.manager.gsrt.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gopay.common.cps.dao.gsrt.GsrtBidsInfoDao;
import com.gopay.common.cps.manager.gsrt.GsrtBidsInfoQueryManager;
import com.gopay.common.domain.gsrt.GsrtBidsInfo;

@Service(value = "gsrtBidsInfoQueryManager")
public class GsrtBidsInfoQueryManagerImpl implements GsrtBidsInfoQueryManager {

	@Resource( name ="gsrtBidsInfoDao")
	private GsrtBidsInfoDao gsrtBidsInfoDao;
	
	@Override
	public List<GsrtBidsInfo> getByMerId_BidNo(String merCustId, String bidNo) {
		String hql="from GsrtBidsInfo where merCustId=:merCustId and bidNo=:bidNo";
		Map<String,Object> paramMap=new HashMap<String,Object>();
		paramMap.put("merCustId", merCustId);
		paramMap.put("bidNo", bidNo);
		List<GsrtBidsInfo> list = gsrtBidsInfoDao.findByHql(hql, paramMap);
		return list;
	}
	
	@Override
    public GsrtBidsInfo getGopayOrderId(String merCustId, String gopayOrderId){
		String hql="from GsrtBidsInfo where merCustId=:merCustId and gopayOrderId=:gopayOrderId";
		Map<String,Object> paramMap=new HashMap<String,Object>();
		paramMap.put("merCustId", merCustId);
		paramMap.put("gopayOrderId", gopayOrderId);
		List<GsrtBidsInfo> list = gsrtBidsInfoDao.findByHql(hql, paramMap);
		return (GsrtBidsInfo)list.get(0);
	}
	@Override
    @Transactional
	public  void update(GsrtBidsInfo  info){
		gsrtBidsInfoDao.update(info);
	}

}
